#ifndef RENDERCONTROLLER_H
#define RENDERCONTROLLER_H

#include <process.h>

#include "RenderGObject.h"
#include "../Utility/Misc/Timer.h"

#define NUM_OBJECTS 32
#define NUM_MATRICES 32

#define NUM_DEBUG_OBJECTS 4
#define NUM_DEBUG_MATRICES 32

#define NUM_PLAYERS 4

enum DEBUG_SHAPE{BOX, PLANE};

class RenderController
{
public:
	RenderController();
	~RenderController();

	static void Initialize();
	static unsigned int LoadObject(const char* const _filePath);
	static void SetStaticObjectPosition(unsigned int _index, float _posX, float _posY, float _posZ);
	static void Render();

	static unsigned int LoadPlayer(const char* const _filePath);
	static void SetPlayerPosition(unsigned int _index, float _posX, float _posY, float _posZ);

	static void SetViewProjection(XMFLOAT4X4 _vp);

	static unsigned int LoadDebugGeometry(DEBUG_SHAPE _shape, float _xScale, float _yScale, float _zScale);
	static void SetDebugGeometryPosition(unsigned int _index, float _posX, float _posY, float _posZ);
	static void RenderDebugGeometry();

	static void RenderHUD();

private:
	struct StaticObjects
	{
		RenderGObject objects[NUM_OBJECTS];
		XMMATRIX world[NUM_OBJECTS][NUM_MATRICES];
	};

	struct DebugGeometry
	{
		RenderGObject objects[NUM_DEBUG_OBJECTS];
		XMMATRIX world[NUM_DEBUG_OBJECTS][NUM_DEBUG_MATRICES];
	};

	static RenderGObject players[NUM_PLAYERS];
	static XMMATRIX playerWorld[NUM_PLAYERS];
	
	static XMMATRIX viewProjection;
	static CRITICAL_SECTION criticalSection;

	static unsigned int lastLoadedPlayer;

	static unsigned int lastLoadedIndex;
	static unsigned int lastLoadedMatrix[NUM_OBJECTS];

	static unsigned int debugLastLoadedIndex;
	static unsigned int debugLastLoadedMatrix[NUM_DEBUG_OBJECTS];

	static StaticObjects staticObjects;
	static DebugGeometry debugGeometry;
	static Timer timer;
};

#endif